import 'package:get/get.dart';

import '../modules/auth/bindings/auth_binding.dart';
import '../modules/auth/views/login_view.dart';
import '../modules/home/bindings/home_binding.dart';
import '../modules/home/views/home_view.dart';
import '../modules/profile/bindings/profile_binding.dart';
import '../modules/profile/views/profile_view.dart';
import '../modules/product/bindings/product_binding.dart';
import '../modules/product/views/product_view.dart';
import '../modules/product/bindings/product_model_binding.dart';
import '../modules/product/views/product_model_view.dart';
import '../modules/product/bindings/product_model_detail_binding.dart';
import '../modules/product/views/product_model_detail_view.dart';
import '../modules/product/bindings/product_detail_binding.dart';
import '../modules/product/views/product_detail_view.dart';
import '../modules/device/bindings/device_binding.dart';
import '../modules/device/views/device_view.dart';
import '../modules/device/bindings/device_detail_binding.dart';
import '../modules/device/views/device_detail_view.dart';
import '../modules/device/bindings/device_data_binding.dart';
import '../modules/device/views/device_data_view.dart';
import '../modules/device/bindings/device_data_table_binding.dart';
import '../modules/device/views/device_data_table_view.dart';
import '../modules/device/views/device_channel_view.dart';
import '../modules/device/views/device_video_play_view.dart';
import '../modules/alert_logs/bindings/alert_logs_binding.dart';
import '../modules/alert_logs/views/alert_logs_view.dart';
import '../services/token_service.dart';
import '../middlewares/auth_middleware.dart';
import 'app_routes.dart';
import '../modules/product/bindings/thing_model_editor_binding.dart';
import '../modules/product/views/thing_model_editor_view.dart';
import '../modules/product/views/json_test_view.dart';

class AppPages {
  AppPages._();

  // 根据登录状态动态决定初始路由
  static String get initial {
    final tokenService = Get.find<TokenService>();
    return tokenService.isLoggedIn() ? Routes.home : Routes.login;
  }

  static final routes = [
    GetPage(
      name: Routes.home,
      page: () => const HomeView(),
      binding: HomeBinding(),
      middlewares: [AuthMiddleware()],
    ),
    GetPage(
      name: Routes.login,
      page: () => const LoginView(),
      binding: AuthBinding(),
      middlewares: [AuthMiddleware()],
    ),
    GetPage(
      name: Routes.profile,
      page: () => const ProfileView(),
      binding: ProfileBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.rightToLeft,
    ),
    GetPage(
      name: Routes.product,
      page: () => const ProductView(),
      binding: ProductBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.productModel,
      page: () => const ProductModelView(),
      binding: ProductModelBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.productModelDetail,
      page: () => const ProductModelDetailView(),
      binding: ProductModelDetailBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.productDetail,
      page: () => const ProductDetailView(),
      binding: ProductDetailBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.device,
      page: () => const DeviceView(),
      binding: DeviceBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.deviceDetail,
      page: () => const DeviceDetailView(),
      binding: DeviceDetailBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.deviceData,
      page: () => const DeviceDataView(),
      binding: DeviceDataBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.deviceDataTable,
      page: () => const DeviceDataTableView(),
      binding: DeviceDataTableBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.deviceVideo,
      page: () => const DeviceChannelView(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.deviceVideoPlay,
      page: () {
        return const DeviceVideoPlayView();
      },
      binding: DeviceDetailBinding(),
    ),
    GetPage(
      name: Routes.alertLogs,
      page: () => const AlertLogsView(),
      binding: AlertLogsBinding(),
      middlewares: [AuthMiddleware()],
      transition: Transition.fadeIn,
    ),
    GetPage(
      name: Routes.THING_MODEL_EDITOR,
      page: () => const ThingModelEditorView(),
      binding: ThingModelEditorBinding(),
      middlewares: [AuthMiddleware()],
    ),
    GetPage(
      name: Routes.JSON_TEST,
      page: () => const JsonTestView(),
      binding: ProductBinding(),
    ),
  ];
} 